//Thu Apr  7 19:56:15 CDT 2011
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class TheProgrammingContestDivTwo
{
public:

    vector <int> find(int T, vector <int> requiredTime)
    {
        sort(requiredTime.begin(), requiredTime.end());
        int penalty = 0;
        int count = 0;
        int time = 0;
        for (int i = 0; i < requiredTime.size(); i++)
        {
            if (time <= T && requiredTime[i] + time <= T)
            {
                count++;
                time += requiredTime[i];
                penalty += time;
            }
        }
        vector<int> ret;
        ret.push_back(count);
        ret.push_back(penalty);
        return ret;
    }
};
